home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #2 / Amiga Plus CD - 1995 - No. 2.iso / pd / mui / mirrormanager / rexx / mirrormanager.rexx < prev    next >
OS/2 REXX Batch file  |  1995-04-11  |  8KB  |  302 lines

  1. /*rx
  2. **  $VER: $Id: MirrorManager.rexx,v 1.13 1994/06/20 01:07:59 tf Exp $
  3. **
  4. **  Initial revision by Tobias Ferber, 4.3.94
  5. **
  6. **  This is the configuration script for the MirrorManager GUI.
  7. **  When loaded from within a MirrorManager application it will configure
  8. **  this application by adding the ListView entries below.
  9. **  However it is also executable via RX. (therefore the extension ".rexx")
  10. **  If executed from outside a MirrorManager host it will look for a host with
  11. **  an empty ListView and it will configure this host if it exists.
  12. **  Otherwise -- if there is no empty MirrorManager ListView available it
  13. **  will run a new MirrorManager GUI application and configure that one.
  14. **
  15. **  Feel free to change the path and filenames below.  This example
  16. **  configuration is designed to fit on my own installation only.
  17. **  Note that MirrorManager needs neither assignments nor environment
  18. **  variables.  All the logical devices below are my personal settings.
  19. **  If you prefer using a different hierarchy then feel free to change
  20. **  the pathnames below to your personal taste or needs.
  21. **
  22. **  You can also use the configure script to change the assignments below.
  23. */
  24.  
  25. /*@*/
  26.  
  27. IncomingPath     = "incoming:"
  28. AminetPath       = "downloads:aminet"
  29. KickedPath       = "downloads:aminet/kicked"
  30. FastIndexPath    = "downloads:aminet/fastindex"
  31. AminetIndexFile  = "downloads:aminet/INDEX"
  32. AminetRecentFile = "downloads:aminet/RECENT"
  33. AminetTreeFile   = "downloads:aminet/TREE"
  34. LocalIndexFile   = "downloads:aminet/LOCAL"
  35. WantedIndexFile  = "downloads:aminet/WANTED"
  36. HiddenFile       = "downloads:aminet/HIDDEN"
  37. IndexedFile      = "downloads:aminet/INDEXED"
  38. RemapFile        = "downloads:aminet/MAP"
  39.  
  40. /*@*/
  41.  
  42. /* There should be no need for you to change the following values */
  43.  
  44. myname           = whoami('resolved')
  45. mm_path          = left(myname,lastpos('/REXX/',upper(myname)))
  46. portbase         = 'MIRRORMANAGER.'
  47. appstart         = "run /MirrorManager"
  48. def_stacksize    = 10240
  49.  
  50.  
  51. /*** / GET HOST / ***/
  52.  
  53. options results
  54.  
  55. if( arg() > 0 ) then do
  56.   parse arg portname
  57.   if abbrev(portname,portbase) then address(portname)
  58.   else do
  59.     say 'Usage:' myname '[ MIRRORMANAGER.<x> ]'
  60.     exit
  61.     end
  62.   end
  63.  
  64. else do
  65.  
  66.   if ~abbrev(address(),portbase) then do
  67.     portlist = SHOW('P',,'0A'X)
  68.     do while words(portlist) > 0
  69.       parse var portlist portname '0A'X portlist
  70.       if abbrev(portname,portbase) then do
  71.         address(portname); 'NUMENTRIES'
  72.         if result = 0 then portlist= ""
  73.                       else address
  74.         end
  75.       end
  76.  
  77.     if address() ~= portname then do
  78.       /*say '"'myname'" running "'appstart'"'*/
  79.       stacksize= pragma('S',def_stacksize)
  80.       address command appstart 'CONFIGNAME="'myname'"'
  81.       call pragma('S',stacksize)
  82.       exit
  83.       end
  84.  
  85.     end
  86.     else portname = address()
  87.   end
  88.  
  89.  
  90. /*** / ADD ITEMS / ***/
  91.  
  92. CLEAR
  93. CONFIGURABLE TRUE
  94.  
  95. /*say '"'myname'" configuring "'address()'"'*/
  96.  
  97. CONFIGNAME '"'myname'"'
  98.  
  99. add_item( 'Create/Update Aminet TREE',,
  100.           'rexx/MakeTree',,
  101.           'FROM' '"'AminetTreeFile'"',
  102.           'TO'   '"'AminetPath'"',
  103.           'AUTO' )
  104.  
  105. add_item( 'Delete Empty Directories',,
  106.           'rexx/CutTree',,
  107.           'PATH' '"'AminetPath'"',
  108.           'AUTO' )
  109.  
  110. add_item( 'Update Aminet DirNotes',,
  111.           'rexx/MakeTree',,
  112.           'FROM' '"'AminetTreeFile'"',
  113.           'TO'   '"'AminetPath'"',
  114.           'NOCREATE',
  115.           'AUTO' )
  116.  
  117. add_item( 'Add FileNotes to INCOMING',,
  118.           'rexx/CleanupIncoming',,
  119.           'FROM' '"'IncomingPath'"',
  120.           'FAST WITH' '"'FastIndexPath'"',
  121.           'AUTO' )
  122.  
  123. add_item( 'Add FileNotes from RECENT',,
  124.           'rexx/CleanupIncoming',,
  125.           'FROM' '"'IncomingPath'"',
  126.           'WITH' '"'AminetRecentFile'"',
  127.           'AUTO' )
  128.  
  129. add_item( 'Add FileNotes from WANTED',,
  130.           'rexx/CleanupIncoming',,
  131.           'FROM' '"'IncomingPath'"',
  132.           'WITH' '"'WantedIndexFile'"',
  133.           'AUTO' )
  134.  
  135. add_item( 'Cleanup INCOMING',,
  136.           'rexx/CleanupIncoming',,
  137.           'MOVE FAST FROM' '"'IncomingPath'"',
  138.           'TO'   '"'AminetPath'"',
  139.           'WITH' '"'FastIndexPath'"',
  140.           'AUTO' )
  141.  
  142. if (right(IncomingPath,1) ~= ':') & (right(IncomingPath,1) ~= '/') then newRecentFile= IncomingPath || '/RECENT'
  143.                                                                    else newRecentFile= IncomingPath || 'RECENT'
  144.  
  145. add_item( 'Cleanup with new RECENT',,
  146.           'rexx/CleanupIncoming',,
  147.           'MOVE FROM' '"'IncomingPath'"',
  148.           'TO'        '"'AminetPath'"',
  149.           'WITH'      '"'newRecentFile'"',
  150.           'AUTO' )
  151.  
  152. add_item( 'Create FAST Index',,
  153.           'rexx/SplitIndex',,
  154.           'FROM' '"'AminetIndexFile'"',
  155.           'TO'   '"'FastIndexPath'"',
  156.           'AUTO' )
  157.  
  158. add_item( 'Create/Update LOCAL Index',,
  159.           'rexx/MakeIndex',,
  160.           'FROM' '"'AminetPath'"',
  161.           'TO'   '"'LocalIndexFile'"',
  162.           'HIDE WITH' '"'HiddenFile'"',
  163.           'AUTO' )
  164.  
  165. add_item( 'Edit LOCAL Index File',,
  166.           '"ADDRESS COMMAND ''ed ""'LocalIndexFile'""''"')
  167.  
  168. add_item( 'Sort LOCAL Index File',,
  169.           'rexx/SortIndex',,
  170.           'FROM' '"'LocalIndexFile'"',
  171.           'AUTO' )
  172.  
  173. add_item( 'Examine LOCAL Index File',,
  174.           'rexx/ExamineIndex',,
  175.           'FAST COMMENT FILE' '"'LocalIndexFile'"',
  176.           'WITH' '"'FastIndexPath'"',
  177.           'PATH' '"'AminetPath'"',
  178.           'AUTO' )
  179.  
  180. add_item( 'Reorganize Local Mirror',,
  181.           'rexx/ExamineIndex',,
  182.           'FILE' '"'LocalIndexFile'"',
  183.           'RELOCATE COMMENT FAST',
  184.           'WITH' '"'FastIndexPath'"',
  185.           'PATH' '"'AminetPath'"',
  186.           'KICK' '"'KickedPath'"',
  187.           'AUTO' )
  188.  
  189. add_item( 'Re-Insert Kicked Out Files',,
  190.           'rexx/CleanupIncoming',,
  191.           'MOVE FROM' '"'KickedPath'"',
  192.           'TO'   '"'AminetPath'"',
  193.           'WITH' '"'LocalIndexFile'"',
  194.           'AUTO' )
  195.  
  196. add_item( 'Sort Aminet INDEX File',,
  197.           'rexx/SortIndex',,
  198.           'FROM' '"'AminetIndexFile'"',
  199.           'AUTO' )
  200.  
  201. add_item( 'Edit Aminet INDEX File',,
  202.           '"ADDRESS COMMAND ''ed ""'AminetIndexFile'""''"')
  203.  
  204. add_item( 'Edit WANTED Index',,
  205.           '"ADDRESS COMMAND ''ed ""'WantedIndexFile'""''"')
  206.  
  207. add_item( 'Edit Configuration Script',,
  208.           '"OPTIONS RESULTS; CONFIGNAME; script= result; ADDRESS COMMAND ''ed ""''script''""''"')
  209.  
  210. add_item( 'Generate brief Status from Log','rexx/Status.mm')
  211.  
  212. EXIT
  213.  
  214. /*@*/
  215.  
  216. /*** / PROCEDURES / ***/
  217.  
  218. add_item: procedure
  219.   parse arg name,command,args
  220.   ADD transquote(name) transquote(command) transquote(args)
  221.   return rc
  222.  
  223. /**/
  224.  
  225. transquote: procedure
  226.   parse arg s
  227.   t= s
  228.   q= max( lastpos('*',s), lastpos('"',s) )
  229.  
  230.   do while q > 0
  231.     t= insert('*',t,q-1,1)
  232.     s= left(s,q-1)
  233.     q= max( lastpos('*',s), lastpos('"',s) )
  234.     end
  235.  
  236.   return '"' || t || '"'
  237.  
  238.  
  239. /*
  240. **  This procedure resolves the scriptfile path and filename
  241. */
  242.  
  243. whoami: procedure
  244.   arg cr
  245.   parse source . . s
  246.  
  247.   /* --> s = <called> <resolved> <extension> <host> */
  248.  
  249.   lib= show('L',"rexxsupport.library")
  250.   if ~lib then lib= addlib("rexxsupport.library",0,-30,0)
  251.  
  252.   if lib then do
  253.  
  254.     vlist= showlist('v',,':') || ':'
  255.     call remlib("rexxsupport.library")
  256.  
  257.     /* find the last position p of a legal volume name (terminated with a colon) in s */
  258.  
  259.     p= 0
  260.     do while (words(vlist) > 0) & (p = 0)
  261.       parse var vlist vol ':' vlist
  262.       p= lastpos(vol':',upper(s))
  263.       end
  264.  
  265.     if p > 1 then called= strip( left(s,p-1) )   /* <called> ends at position (p-1) */
  266.     end
  267.  
  268.   else do /* ~rexxsupport.library */
  269.  
  270.     t= left(s,lastpos(':',s))
  271.     called= strip( left(t,lastpos(' ',t)) )
  272.  
  273.     call pragma('W','N')
  274.     do while ~exists(called) & lastpos(' ',called) > 0
  275.       called= left(called,lastpos(' ',called)-1)
  276.       end
  277.  
  278.     end
  279.  
  280.   /* extract <resolved> from s */
  281.  
  282.   if left(cr,1) = 'R' then do
  283.     host= address()
  284.     parse var s (called) s (host) .
  285.  
  286.     /* --> s = <resolved>              if  <extension>  = <host>
  287.        or  s = <resolved> <extension>  if  <extension> ~= <host> */
  288.  
  289.     resolved= strip(s)
  290.  
  291.     call pragma('W','N')
  292.     do while ~exists(resolved)
  293.       resolved= left(resolved,lastpos(' ',resolved)-1)
  294.       end
  295.  
  296.     end
  297.  
  298.   if left(cr,1) = 'R' then return resolved
  299.                       else return called
  300.  
  301. /* END */
  302.